<template>
  <view v-if="shenheStatus == 0" class="withdraw">
    <view class="header-tabs">
      <u-tabs
        :list="tabList"
        :current="current"
        active-color="#FA230A"
        item-width="25%"
        @change="tabsChange"
        height="44"
        inactive-color="#262626"
      ></u-tabs>
    </view>
    <view class="commissionList">
      <view
        class="commissionItem"
        v-for="(item, index) in cashList"
        :key="index"
      >
        <view class="icon">
          <text class="iconfont">&#xe792;</text>
        </view>
        <view class="commissionBox">
          <view class="info">
            <text>{{
              item.type == 0
                ? $t("adminPage.withdrawWechat")
                : item.type == 1
                ? $t("adminPage.withdrawAli")
                : item.type == 2
                ? $t("adminPage.withdrawBank")
                : $t("adminPage.withdrawBalance")
            }}</text>
            <text>{{ $t("shareholder.withTime") }}：{{ item.created_at }}</text>
            <text v-if="item.status != 0"
              >{{ $t("shareholder.checkTime") }}：{{ item.audit_time }}</text
            >
          </view>
          <view class="count">
            <text>+{{ item.price }}</text>
            <text class="red" v-if="item.status == 0">{{
              $t("person.cashStatus2")
            }}</text>
            <text class="red" v-if="item.status == 1">{{
              $t("shareholder.confirmApply")
            }}</text>
            <text v-if="item.status == 2">{{ $t("person.cashStatus4") }}</text>
            <text class="red" v-if="item.status == 3">{{
              $t("shareholder.refuced")
            }}</text>
          </view>
        </view>
      </view>
    </view>
    <view class="empty" style="padding-top: 50rpx">
      <u-empty mode="data" v-if="!cashList.length"></u-empty>
    </view>
  </view>
  <Shenhe v-else-if="shenheStatus == 1"></Shenhe>
</template>

<script>
import Shenhe from "@/components/shenhe/shenhe";
export default {
  components: { Shenhe },
  data() {
    return {
      current: 0,
      tabList: [
        {
          name: this.$t("person.cashStatus1"),
          status: 0,
        },
        {
          name: this.$t("person.cashStatus2"),
          status: 1,
        },
        {
          name: this.$t("person.cashStatus4"),
          status: 2,
        },
        {
          name: this.$t("shareholder.refuced"),
          status: 3,
        },
      ],
      // 提现列表
      cashList: [],
      // 当前加载页面
      page: 1,
      // 是否加载完毕
      noMore: false,

      is_area: "",
    };
  },
  methods: {
    // 获取提现列表
    async getOrders() {
      let status = this.current - 1;
      const res = await this.$allrequest.shareholder.cashDetail(
        {
          page: this.page,
          status,
          is_area: this.is_area,
        },
        true
      );
      if (res.code == 0) {
        this.cashList = [...this.cashList, ...res.data.list];
        if (this.cashList.length >= res.data.row_count) {
          this.noMore = true;
        } else {
          this.noMore = false;
        }
      }
    },
    // 切换导航
    tabsChange(e) {
      if (e == this.current) return;
      this.page = 1;
      this.cashList = [];
      this.noMore = false;
      this.current = e;
      this.getOrders();
    },
  },
  onLoad(option) {
    if (option.status) {
      this.current = option.status;
    }

    if (option.is_area) {
      this.is_area = "1";
    }
  },
  onShow() {
    this.cashList = [];
    this.page = 1;
    this.noMore = false;
    this.getOrders();
  },
  onReachBottom() {
    if (!this.noMore) {
      this.page++;
      this.getOrders();
    }
  },
};
</script>

<style lang="scss" scoped>
.withdraw {
  min-height: 100vh;
  background-color: #f2f2f2;
  font-family: PingFang SC;
  color: #262626;
  padding-top: 90rpx;
}
.header-tabs {
  width: 100%;
  padding-top: 20rpx;
  height: 90rpx;
  // line-height: 90rpx;
  background: #ffffff;
  position: fixed;
  top: 0;
  z-index: 1000;
  left: 0;
}
.commissionList {
  margin-top: 24rpx;
  background-color: #fff;
  padding-left: 30rpx;
  .commissionItem {
    padding-top: 30rpx;
    display: flex;
    .icon {
      width: 70rpx;
      height: 70rpx;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      background-color: #f83c08;
      .iconfont {
        font-size: 48rpx;
        color: #ffffff;
      }
    }
    .commissionBox {
      flex: auto;
      margin-left: 24rpx;
      padding: 0 30rpx 30rpx 0;
      display: flex;
      justify-content: space-between;
      border-bottom: 1px solid #f8f8f8;
      .info {
        display: flex;
        flex-direction: column;
        font-size: 24rpx;
        color: #8c8c8c;
        text:nth-child(1) {
          font-size: 28rpx;
          color: #262626;
          margin: 14rpx 0;
        }
        text:nth-child(2) {
          margin-bottom: 8rpx;
        }
      }
      .count {
        display: flex;
        align-items: flex-end;
        flex-direction: column;
        font-size: 26rpx;
        color: #8c8c8c;
        text:nth-child(1) {
          font-size: 36rpx;
          font-weight: 600;
          color: #262626;
          margin-bottom: 4rpx;
        }
        .red {
          color: #f0250e;
        }
      }
    }
  }
  .commissionItem:last-child {
    .commissionBox {
      border-bottom: none;
    }
  }
}
</style>
